<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>添加角色</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
    <div class="layui-container" style="padding-top:30px;">
      <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称</label>
            <div class="layui-input-block">
              <input type="text" name="name" required  placeholder="请输入角色名称" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">角色描述</label>
            <div class="layui-input-block">
              <textarea name="remark" placeholder="请输入描述" class="layui-textarea"></textarea>
            </div>
          </div>
        <div class="layui-form-item">
          <label class="layui-form-label">状态</label>
          <div class="layui-input-block">
            <input type="radio" name="status" value="1"  checked title="启用">
            <input type="radio" name="status" value="0" title="禁用">
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formAdd">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
      </form>
    </div>
    <script src="/static/layui/layui.js"></script>
    <script>
      //Demo
      layui.use('form', function(){
        var form = layui.form,$ = layui.jquery;
        form.on('submit(formAdd)',function(data){
            $.post('/admin/role/save',data.field,function(res){
                  if(res.code ==1 ){
                    let index =  parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.$.pjax({container: '#main',fragment: '#main'}).reload;
                  }

                  return layer.msg(res.msg,{icon:2});
            });
        });
      });
      </script>
</body>
</html>
